package com.woniu.dao;

import com.woniu.entity.Course;
import com.woniu.entity.User;
import com.woniu.entity.Vedio;
import com.woniu.entity.vo.Information;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseInfoDao {
    @Select("select * from vedio where course_id=#{id}")
    List<Vedio> queryCourseInfo(Integer id);

    @Select("select * from course where id= #{id}")
    Course selectCourseInfo(Integer id);

    //修改课程信息
    @Update("update course set " +
            "title=#{title}," +
            "description=#{description}," +
            "price=#{price}," +
            "cover=#{coverUrl},"+
            "teacher_id=#{teacher} where id=#{id}")
    void amend(Information information);

    //下架操作
    @Update("update course set enable=1 where id=#{id}")
    void SoldOut(Integer id);
//删除操作
    @Update("update course set enable=2 where id= #{id}")
    void Delect(Integer id);

    //查询学员信息
    List<User> QueryUser(Integer id);

    //上架操作
    @Update("update course set enable=0 where id=#{id}")
    void ShelvingOperation(Integer id);

    @Select("SELECT * FROM vedio\n" +
            "WHERE course_id = #{id}\n" +
            "and  title= #{name}")
    Integer selectVideoUrl(@Param("id") String id, @Param("name") String name);


void addvideoUrl(Information information);

@Delete("delete from vedio where id=#{id}")
    void DelectID(Integer id);
}
